<?php
/**
 * restructured text documentation page object, to be used within webappkit admin
 *
 * This file is part of Webappkit, a packages system for PHP web apps
 * @link http://webappkit.net
 * @package webappkit
 * @subpackage admin
 * @author J.Ducastel <nospam0@ducastel.name>
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 */
class WakRestDocPage extends WakTextFile implements iWakDocPage {

    /**
     *
     * @return string
     */
    public function getPageLabel() {
        $label=$this->getpageid();
        $label=str_ireplace('.rst.txt','',$label);
        $label=str_ireplace('.rest.txt','',$label);
        return str_replace('_',' ',$label);
    }

    public function getPageId() {
        return $this->basename();
    }

    /**
     * returns documentation page content parsed as HTML
     * @return string
     */
    public function getPageContent() {
        // requires text_rest kit
        Webappkit::loadkit('text_rest');
        $node=Text_reST::parse($this->getContent());
        $formatter=new Text_reST_Formatter_html();
        return $formatter->format($node);
        echo '<pre>'; return var_dump($node);
        return $this->getContent();
    }
}